package com.example.shiyanyi;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    EditText wenben1;
    EditText wenben2;
    TextView tv;
    Button bt;
    int sum;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        wenben1 = findViewById(R.id.et1);
        wenben2 = findViewById(R.id.et2);
        tv = findViewById(R.id.tv);
        bt=findViewById(R.id.bt);
        bt.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        String s1=wenben1.getText().toString();
        String s2=wenben2.getText().toString();
        int num1=Integer.valueOf(s1).intValue();
        int num2=Integer.valueOf(s2).intValue();
        sum=num1+num2;
        s1=String.valueOf(sum);
        tv.setText(s1);
    }
}